TypeScript 97.4%
SQL 1%
JavaScript 0.9%
CSS 0.6%
1import { withUser, ApiError } from "@/lib/api";2import { exportArenaSession } from "@/lib/arena/service";3import { LIMITS } from "@/lib/rate-limit";45export const dynamic = "force-dynamic";6type P = { id: string };78/** POST /api/arena/:id/export?format=markdown|json → file download (models, parameters, metrics, votes, responses). */9export const POST = withUser<P>(10 async ({ req, user }, { id }) => {11 const format = new URL(req.url).searchParams.get("format") ?? "markdown";12 if (format !== "markdown" && format !== "json" && format !== "md") throw new ApiError(400, "format must be markdown or json", "VALIDATION_ERROR");13 const out = await exportArenaSession(user.id, id, format === "json" ? "json" : "markdown");14 return new Response(out.body, { headers: { "Content-Type": out.contentType, "Content-Disposition": `attachment; filename="${out.filename}"`, "X-Filename": out.filename } });15 },16 { limit: { ...LIMITS.share, key: "arena-export" } },17);18